package com.hospitalsystem.controller;

import com.hospitalsystem.entity.Arrange;
import com.hospitalsystem.entity.State;
import com.hospitalsystem.service.PatientService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * (Patient)表控制层
 *
 * @author makejava
 * @since 2024-12-28 19:32:59
 */
@RestController
@RequestMapping("patient")
public class PatientController {
    /**
     * 服务对象
     */
    @Resource
    private PatientService patientService;

    /**
     * 分页查询
     *
     * @param patient 筛选条件
     * @param pageRequest      分页对象
     * @return 查询结果
     */
//    @GetMapping
//    public ResponseEntity<Page<Patient>> queryByPage(Patient patient, PageRequest pageRequest) {
//        return ResponseEntity.ok(this.patientService.queryByPage(patient, pageRequest));
//    }

    /**
     * 通过主键查询单条数据
     *
     * @param pId
     * @return 单条数据
     */
//    @GetMapping("{id}")
//    public ResponseEntity<Patient> queryById(@PathVariable("id")String pId) {
//        return ResponseEntity.ok(this.patientService.queryById(pId));
//    }

    /**
     * 新增数据
     *
     * @param patient 实体
     * @return 新增结果
     */
//    @PostMapping
//    public ResponseEntity<Patient> add(Patient patient) {
//        return ResponseEntity.ok(this.patientService.insert(patient));
//    }

    /**
     * 编辑数据
     *
     * @param patient 实体
     * @return 编辑结果
     */
//    @PutMapping
//    public ResponseEntity<Patient> edit(Patient patient) {
//        return ResponseEntity.ok(this.patientService.update(patient));
//    }

    /**
     * 删除数据
     *
     * @param pId
     * @return 删除是否成功
     */
//    @DeleteMapping
//    public ResponseEntity<Boolean> deleteById(String pId) {
//        return ResponseEntity.ok(this.patientService.deleteById(pId));
//    }


    //患者登录系统
    @GetMapping("login")
    public ResponseEntity<State> login(@RequestParam String id, @RequestParam String password){
        return ResponseEntity.ok(this.patientService.login(id,password));
    }

    //获取所有医生科室
    @GetMapping("getDepartment")
    public ResponseEntity<List<String>> getDepartment(){
        return ResponseEntity.ok(this.patientService.getDepartment());
    };

    //获取某个科室医生list
    @GetMapping("getDoctorByDepartment")
    public ResponseEntity<Map<String,Integer>> getDoctorByDepartment(@RequestParam String department, @RequestParam String time){
        return ResponseEntity.ok(this.patientService.getDoctorByDepartment(department,time));
    }

    //建立一个预约单
    @GetMapping("addArrange")
    public ResponseEntity<Arrange> addArrange(@RequestParam String pid, @RequestParam String did, @RequestParam String time){
        return ResponseEntity.ok(this.patientService.addArrange(pid,did,time));
    }

    //预约单缴费
//    @GetMapping("chargeForArrange")
//    public ResponseEntity<State> chargeForArrange(@RequestParam String arrangeid){
//        return ResponseEntity.ok(this.patientService(arrangeid));
//    }

    //获取排队队列
    @GetMapping("getQueue")
    public ResponseEntity<List<Map<String,Object>>> getQueue(@RequestParam String did){
        return ResponseEntity.ok(this.patientService.getQueue(did));
    }
}

